package metrics;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Random;

import thesis.InfoUnit;
import thesis.DataObject;
import thesis.Summary;


public class Rouge {
	public static double getScore(final Summary summary, final Collection<DataObject> allData,
			final ArrayList<InfoUnit> units, final double[][] probs) {
		double total = 0, match = 0;
		for (InfoUnit unit : units) {
			boolean hit = false;
			for (DataObject t : summary.getMemoryTweets()) {
				if (probs[t.getInternId()][unit.getInternId()] == 1) {
					hit = true;
					break;
				}
			}
			for (DataObject t : allData) {
				if (probs[t.getInternId()][unit.getInternId()] == 1) {
					total += unit.getWeight();
					if (hit) {
						match += unit.getWeight();
					}
				}
			}
		}
		return match / total;
	}
}
